package com.example.opengldemo.vertex_magical.shader;

import android.content.res.Resources;

import com.example.opengldemo.util.MatrixState;


public class OesRenderer extends BaseRenderer {
    public OesRenderer(Resources resource) {
        super(resource,"vertexmagical/oes_vert.sh", "vertexmagical/oes_frag.sh");
    }

    public OesRenderer(){
        super(null,
                "#version 300 es\n" +
                        "in vec3 aPosition;\n" +
                        "in vec2 aTexCoors;\n" +
                        "\n" +
                        "uniform mat4 uMVPMatrix ;\n" +
                        "uniform mat4 uTMatrix;\n" +
                        "\n" +
                        "out vec2 vTextureCo;\n" +
                        "\n" +
                        "void main(){\n" +
                        "    gl_Position = uMVPMatrix*vec4(aPosition,1) ;\n" +
                        "    vTextureCo = (uTMatrix*vec4(aTexCoors,0,1)).xy;\n" +
                        "}",
                "#version 300 es\n" +
                        "#extension GL_OES_EGL_image_external_essl3 : require\n" +
                        "precision mediump float;\n" +
                        "in vec2 vTextureCo;\n" +
                        "uniform samplerExternalOES sTexture;\n" +
                        "layout(location=0) out vec4 fragColor;\n" +
                        "void main() {\n" +
                        "    fragColor = texture( sTexture, vTextureCo);\n" +
                        "}");
    }

    @Override
    protected void onBindTexture(int textureId) {
       shaderHandle.bindDefaultOesTextureHandle(textureId);
    }

    @Override
    protected void onSetExpandData() {
        super.onSetExpandData();
        //shaderHandle.bindMVPMaxtrixHandle(MatrixState.getFinalMatrix());
        //shaderHandle.bindTMaxtrixHandle(MatrixState.getFinalMatrix());
    }
}
